<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://www.bstek.com/dorado" prefix="d" %>
<%@ page import="com.bstek.dorado.data.db.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.bstek.dorado.utils.variant.VariantSet" %>

<html>
<head>
<title>生成组织结构图</title>

<style type="text/css">
<!--
.speis {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 5px; PADDING-TOP: 0px;
	text-align:center;
}
*{
	font-size:12px;
}
#LoadBox{
	text-align:center;
	margin-top:200px;
}
-->
</style>
<script src="../js/organization.js"></script>
</head>
<body>
  
<!--<%@ include file="/jsp/js/organization.js" %>-->
 <div style="width: 100%; height: 100%; overflow: auto">
 <d:View config="com.xr.org.createOrg">

 <div id="LoadBox">组织结构图正在生成，请不要刷新或者关闭窗口,稍后……</div>

 <script language="javascript">
 <%
String comId=request.getParameter("comId");

 
 
 DBStatement dbs=new DBStatement();
 String comSql="select * from org_company com start with com.company_id="+comId+" and com.dr=0 connect by prior com.company_id= com.super_company_id";
 String deptSql="select * from org_dept d start with d.super_dept_id is null and d.company_id in(select com.company_id from org_company com start with com.company_id = "+comId+" and com.dr = 0 connect by prior com.company_id = com.super_company_id)and d.dr=0 connect by prior d.dept_id = d.super_dept_id";
 dbs.setSql(comSql);
 List comList=dbs.queryForList();
 dbs.setSql(deptSql);
 List deptList=dbs.queryForList();
 
 
 
 for(int i=0;i<comList.size();i++){
 VariantSet comVs =(VariantSet)comList.get(i);
 %>
 
 if(!window.com<%=comVs.getString("company_id")%>){
 	var com<%=comVs.getString("company_id")%>=new OrgNode();
 	com<%=comVs.getString("company_id")%>.Text='<%=comVs.getString("company_name")%>';
 	
 	
 }
 <%
if(comVs.getString("super_company_id")!=null){%>

 if(!window.com<%=comVs.getString("super_company_id")%>){
 	var com<%=comVs.getString("super_company_id")%>=new OrgNode();
 }
com<%=comVs.getString("super_company_id")%>.Nodes.Add(com<%=comVs.getString("company_id")%>);
 
<%}%>	

 
<%}%>

<%
for(int i=0;i<deptList.size();i++){
VariantSet deptVs =(VariantSet)deptList.get(i);
%>

if(!window.dept<%=deptVs.getString("dept_id")%>){
 	var dept<%=deptVs.getString("dept_id")%>=new OrgNode();
 	dept<%=deptVs.getString("dept_id")%>.Text='<%=deptVs.getString("dept_name")%>';
 }
<%
if(deptVs.getString("super_dept_id")!=null){%>

 if(!window.dept<%=deptVs.getString("super_dept_id")%>){
 	var dept<%=deptVs.getString("super_dept_id")%>=new OrgNode();
 }
dept<%=deptVs.getString("super_dept_id")%>.Nodes.Add(dept<%=deptVs.getString("dept_id")%>);
<%}else{%>
com<%=deptVs.getString("company_id")%>.Nodes.Add(dept<%=deptVs.getString("dept_id")%>);
 <%}%>
 
 
 <%}%>

 
 
var OrgShows=new OrgShow(com<%=comId%>);
OrgShows.Top=0;
OrgShows.Left=0;
OrgShows.IntervalWidth=5;
OrgShows.IntervalHeight=20;
 OrgShows.ShowType=2;
OrgShows.BoxHeight=0;
OrgShows.LineSize=3;
//OrgShows.BoxTemplet="<div id=\"{Id}\" class=\"OrgBox\"><img src=\"{EmpPhoto}\" /><span>{EmpName}</span><div>{department}</div></div>"
OrgShows.Run();
$("LoadBox").style.display="none";

 
</script>
<%dbs.close(); %> 
 </d:View>
</div>
</body>
</html>
